/**
 * Description:
 * Class Name:GenderTest
 * Date:2022/2/12 16:08
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_9_枚举类._6_9_3_枚举类的成员变量和方法和构造器;

public class GenderTest {
    public static void main(String[] args) {
        // 通过Enum的valueOf()方法来获取知道的枚举类的枚举值
        Gender g = Enum.valueOf(Gender.class, "FEMALE");
        // 直接为枚举值的name实例变量赋值
        g.name = "女";
        // 直接访问枚举值的name实例变量
        System.out.println(g + "代表：" + g.name);

        // ----------------------------
        System.out.println("\nNow is better");
        betterGender b = betterGender.FEMALE;
        b.setName("女");
        System.out.println(b + "代表：" + b.getName());
        // 此时对FEMALE实例变量设置name值时将会提示参数错误
        b.setName("男");
        System.out.println(b + "代表：" + b.getName());

        // ------------------------------
        System.out.println("\nNow is best");
        bestGender c = bestGender.FEMALE;
        System.out.println(c.getName());

    }
}
